package com.medusa.gruul.payment.service.service.impl;

import com.medusa.gruul.common.model.enums.PayType;
import com.medusa.gruul.common.web.handler.Handler;
import com.medusa.gruul.common.web.util.SpringUtils;
import com.medusa.gruul.payment.api.enums.TradeStatus;
import com.medusa.gruul.payment.service.common.annotation.PayStatusVerifyHandler;
import com.medusa.gruul.payment.service.service.MultiPayVerifyService;
import org.springframework.stereotype.Service;

/**
 * 支付状态校验Impl
 *
 * @author xiaoq
 * @ Description MultiPayVerifyServiceImpl.java
 * @date 2022-08-01 15:40
 */
@Service
public class MultiPayVerifyServiceImpl implements MultiPayVerifyService {
	/**
	 * 校验支付状态
	 *
	 * @param payType    支付渠道枚举
	 * @param outTradeNo 外部订单号
	 * @return 交易状态
	 */
	@Override
	public TradeStatus verifyPayStatus(PayType payType, String outTradeNo) {
		Handler<TradeStatus> tradeStatusHandler = SpringUtils.getBean(PayStatusVerifyHandler.class, payType);
		return tradeStatusHandler.handle(outTradeNo);
	}
}
